package edu.thu.studio.ormdesigner.outline;

import org.eclipse.gef.EditPart;
import org.eclipse.gef.EditPartFactory;

import edu.thu.studio.ormdesigner.model.ORMModel;
import edu.thu.studio.ormdesigner.model.diagram.Diagram;
import edu.thu.studio.ormdesigner.model.diagram.DiagramSet;
import edu.thu.studio.ormdesigner.model.diagram.node.TableNode;
import edu.thu.studio.ormdesigner.model.diagram.node.TableNodeSet;
import edu.thu.studio.ormdesigner.model.diagram.node.ViewNode;
import edu.thu.studio.ormdesigner.model.diagram.node.ViewNodeSet;
import edu.thu.studio.ormdesigner.model.domain.Domain;
import edu.thu.studio.ormdesigner.model.domain.DomainSet;
import edu.thu.studio.ormdesigner.outline.editpart.DiagramOutlineEditPart;
import edu.thu.studio.ormdesigner.outline.editpart.DiagramSetOutlineEditPart;
import edu.thu.studio.ormdesigner.outline.editpart.DomainOutlineEditPart;
import edu.thu.studio.ormdesigner.outline.editpart.DomainSetOutlineEditPart;
import edu.thu.studio.ormdesigner.outline.editpart.ORMModelOutlineEditPart;
import edu.thu.studio.ormdesigner.outline.editpart.TableNodeOutlineEditPart;
import edu.thu.studio.ormdesigner.outline.editpart.TableNodeSetOutlineEditPart;
import edu.thu.studio.ormdesigner.outline.editpart.ViewNodeOutlineEditPart;
import edu.thu.studio.ormdesigner.outline.editpart.ViewNodeSetOutlineEditPart;

public class OutlineEditPartFactory implements EditPartFactory {
    
    public EditPart createEditPart(EditPart context, Object model) {
        EditPart editPart = null;
        
        if (model instanceof ORMModel) {
            editPart = new ORMModelOutlineEditPart();
            
        } else if (model instanceof DiagramSet) {
            editPart = new DiagramSetOutlineEditPart();
            
        } else if (model instanceof Diagram) {
            editPart = new DiagramOutlineEditPart();
            
        } else if (model instanceof ViewNodeSet) {
            editPart = new ViewNodeSetOutlineEditPart();
            
        } else if (model instanceof ViewNode) {
            editPart = new ViewNodeOutlineEditPart();
            
        } else if (model instanceof TableNodeSet) {
            editPart = new TableNodeSetOutlineEditPart();
            
        } else if (model instanceof TableNode) {
            editPart = new TableNodeOutlineEditPart();
            
        } else if (model instanceof DomainSet) {
            editPart = new DomainSetOutlineEditPart();
            
        } else if (model instanceof Domain) {
            editPart = new DomainOutlineEditPart();
            
        }
        
        if (editPart != null) {
            editPart.setModel(model);
        }
        
        return editPart;
    }
}
